﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Gonte.Xml.Serialization;
using Gonte.Collections;

namespace MyUtilitiesTest
{
    /// <summary>
    /// Tests an enumeration
    /// </summary>
    public enum EnumerationTest
    {
        EnumItem1 = 10,
        EnumItem2 = 20,
        EnumItem3 = 30
    }

    /// <summary>
    /// Tests the different propertyInfo accessors
    /// </summary>
    public class ObjectToTestPropertyAccessors
    {
        public enum EnumStatus
        {
            Tested = 1,
            NotTested = 2
        }

        private EnumStatus status_;

        public EnumStatus Status
        {
            get { return status_; }
            set { status_ = value; }
        }

        private DateTime date_;

        public DateTime Date
        {
            get { return date_; }
            set { date_ = value; }
        }

        private Guid id_;

        public Guid Id
        {
            get { return id_; }
            set { id_ = value; }
        }

        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        private int? age_;

        public int? Age // Nullable field
        {
            get { return age_; }
            set { age_ = value; }
        }

    }

    /// <summary>
    /// Tests a complex object with few primitives and two collections
    /// </summary>
    public class ObjectWithPrimitivesTest
    {
        private String stringProp_;

        public String StringProp
        {
            get { return stringProp_; }
            set { stringProp_ = value; }
        }
        private Guid guidProp_;

        public Guid GuidProp
        {
            get { return guidProp_; }
            set { guidProp_ = value; }
        }
        private DateTime datetimeProp_;

        public DateTime DatetimeProp
        {
            get { return datetimeProp_; }
            set { datetimeProp_ = value; }
        }
        private Decimal decimalProp_;

        public Decimal DecimalProp
        {
            get { return decimalProp_; }
            set { decimalProp_ = value; }
        }
        private double doubleProp_;

        public double DoubleProp
        {
            get { return doubleProp_; }
            set { doubleProp_ = value; }
        }
        private int intProp_;

        public int IntProp
        {
            get { return intProp_; }
            set { intProp_ = value; }
        }
    }

    public class ObjectWithInnerObjectAndPrimitivesTest
    {
        private String stringProp_;

        public String StringProp
        {
            get { return stringProp_; }
            set { stringProp_ = value; }
        }
        private ObjectWithPrimitivesTest innerObject_;

        public ObjectWithPrimitivesTest InnerObject
        {
            get { return innerObject_; }
            set { innerObject_ = value; }
        }
        private int intProp_;

        public int IntProp
        {
            get { return intProp_; }
            set { intProp_ = value; }
        }

    }

    public class SimpleParentObject
    {
        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        private List<SimpleChildObject> children_ = new List<SimpleChildObject>();

        public List<SimpleChildObject> Children
        {
            get { return children_; }
            set { children_ = value; }
        }
    }

    [XmlRoot("MyObject")]
    public class SimpleObjectWithRootAttribute
    {
        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }
    }

    [XmlConstructorParameter(ParameterType=typeof(SimpleParentObject), AttributeName="@Parent")]
    public class SimpleChildObject
    {
        public SimpleChildObject(SimpleParentObject parent)
        {
            parent_ = parent;
        }

        private String name_;

        public String Name
        {
            get { return name_; }
            set { name_ = value; }
        }

        private readonly SimpleParentObject parent_;

        [XmlIgnore()]
        public SimpleParentObject Parent
        {
            get { return parent_; }
        } 
    }

    /// <summary>
    /// It does not implement the IComparable interface
    /// </summary>
    public class NotComparable  {}

    public class ObjectMissingDictionaryItemAttribute
    {
        StringKeyDictionary<String> dictionary_ = new StringKeyDictionary<String>();

        // DictionaryItemAttribute is missing
        public StringKeyDictionary<String> Dictionary
        {
            get { return dictionary_; }
            set { dictionary_ = value; }
        }
    }

    public class ObjectWithStringKeyDictionaryOfStrings
    {
        StringKeyDictionary<String> values_ = new StringKeyDictionary<String>();

        [DictionaryItemAttribute(KeyName = "Key")]
        public StringKeyDictionary<String> Values
        {
            get { return values_; }
            set { values_ = value; }
        }
    }

}
